#region Imported Namespaces
using System;
using System.Collections.Specialized;
using System.Data;
using System.Web.UI.WebControls;

using PHSRAG.Insight21.Context;
using BO = PHSRAG.Insight21.BusinessObjects;
using DataAccess = PHSRAG.Utility.DataAccess;
using ICachePolicy = PHSRAG.Insight21.Policy.ICachePolicy;
using GenerateKey = PHSRAG.Insight21.BusinessObjects.ModuleKey;
#endregion


namespace PHSRAG.Insight21.SearchContext
{
	#region Class COISearchContext
	/// <summary>
	/// The COISearchContext class encapsulates the search context associated with the COISearch control.
	//  this control is used for Supervisor summary and hierarchy maintenance pages in the Conflict of Intereset nodule.
	/// </summary>
	public class COISearchContext : SearchContext
	{
		#region Constants
		private static string COISearchContextKey = GenerateKey.MakeKey("COISearchContext_0B73095C-1D47-481e-A07E-1AA9918AD3D8",GenerateKey.COI);
		#endregion

		#region Private Types
		/// <summary>
		/// The DataTableIndex enumeration defines the index of each table (which holds data pertaining to the set of
		/// drop-down-lists) within the data container.
		/// </summary>
		private enum DataTableIndex
		{
			Role
		}
		#endregion

		#region Constructor
		/// <summary>
		/// Create an instance of the COISearchContext class. Since this object does not hold any state (other than
		/// whatever the base class holds), there is nothing to initialize.
		/// </summary>
		/// <param name="cachePolicy">Cache policy to use</param>
		public COISearchContext(ICachePolicy cachePolicy)	: base(cachePolicy)
		{
		}
		#endregion

		#region Public Properties
		/// <summary>
		/// Get the key to be used in all caching operations for this instance of the object.
		/// </summary>
		public static string CacheKey	{ get { return COISearchContextKey; } }
		
		/// <summary>
		/// Get the data table from the data container which contains data for the status drop-down-list.
		/// </summary>
		public DataTable RoleData
		{
			get { return DataContainer.Tables[(int)DataTableIndex.Role]; }
		}
		#endregion

		#region BusinessObject Methods
		/// <summary>
		/// Cache this instance of the COISearchContext object using the current cache policy.
		/// </summary>
		public override void Cache()
		{
			CachePolicy.Cache(CacheKey, this);
		}

		/// <summary>
		/// Load COI search data into the data container. The loading is done by invoking a stored procedure.
		/// </summary>
		/// <param name="connectionString">Connection string to the database</param>
		/// <param name="args">Arugments to the invoked stored procedure</param>
		public override void Load(string connectionString, params object[] args)
		{
			UserContext userContext = CachePolicy.GetCachedObject(UserContext.CacheKey) as UserContext;
			System.Diagnostics.Trace.Assert(userContext != null);

//			DataContainer = DataAccess.GetDataSet(connectionString, "GetCOISearchData",
//				DataAccess.BuildSqlParameterArray("@domainUserID", SqlDbType.Int, userContext.DomainUserId));

		}

		/// <summary>
		/// Remove this instance of the COISearchContext object from the cache using the current cache policy.
		/// </summary>
		public override void UnCache()
		{
			CachePolicy.UnCache(CacheKey);
		}
		#endregion

		#region SearchContext Members
		/// <summary>
		/// Reset the internal search state.
		/// </summary>
		public override void Reset(string pageName)
		{
		}
		#endregion
	}
	#endregion
}
